package cn.kevinproject.dingtalk_robot.controller;

import cn.kevinproject.dingtalk_robot.datacenter.DataSender;
import lombok.RequiredArgsConstructor;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author kevin lau
 */
@RestController
@RequestMapping("data")
@RequiredArgsConstructor
public class DataController {

    private final DataSender dataSender;

    @GetMapping("grab")
    public String grab(String key,String robot) {
        if (!StringUtils.hasText(key)||!StringUtils.hasText(robot)) {
            return "获取热搜失败";
        }
        dataSender.send(key,robot);
        return "获取热搜成功";

    }
}
